#pragma once

#include "Map.h"

#include "IBase.h"
#include "Graph.h"
#include "GamerProfile.h"
#include <string>
#include <map>

#define NUM_LEVELS 6
using namespace std;
class BaseObject;
class SpawnDoor;
class EntityManager;
class Player;
class EnemyUnit;

struct TileSets
{
	Tile pTiles;
	Tile edges;
	Layer layers;
	SGD::Size tileSize;
	Map map;
};



class MapManager : public IBase
{
	TileSets tStruct;
	SGD::HTexture tileTexture = SGD::INVALID_HANDLE;
	std::string levels[NUM_LEVELS];
	int startRow, startCol, endRow, endCol;
	
public:

	static MapManager * GetInstance(void);

	BaseObject* LoadLevel(GamerProfile& currProfile, EntityManager*, vector<SGD::Rectangle*>& FOVCollidables, Graph<SGD::Point*>& navGraph);
	void UnloadLevel(void);
	virtual void Render() override;
	virtual void Update(float elapsedTime) override;
	virtual void HandleCollision(const IBase* pOther) override;
	virtual int		GetType(void)	const override { return 10; }
	virtual SGD::Rectangle GetRect(void)	const override{ return SGD::Rectangle(0.0f, 0.0f, 0.0f, 0.0f); }
	virtual void	AddRef(void) override{};
	virtual void	Release(void) override{};

	void SetMapTexture(SGD::HTexture hText) { tileTexture = hText; }

	SGD::HTexture GetMapTexture()			{ return tileTexture; }

	void UnloadTexture(SGD::HTexture);
	void LoadLevelPaths(void);

	Player* CreatePlayer(int type, SGD::Point pos, EntityManager*);
	void CreateSpawner(int type, int graphIndex, int numEnemies, std::vector<int>& waypoints, SGD::Point pos, EntityManager* entities);
	void CreateComputer(SGD::Point pos, EntityManager* entities, const char* event1 = nullptr, const char* event2 = nullptr);

	//void CreateSecurityCamera(void);
	//void CreateOfficer(void);
//	void CreateEliteGuard(SpawnDoor* owner);
//	void CreateLightGuard(void);
///	void CreateTurret(void);
//	void CreateBullet(EnemyUnit* owner);
//	void CreateDog(SpawnDoor* owner);
//	void CreateDesk();
	void CreateEnemy(int type, int homeNode, int alarmNode, int startState, SGD::Point pos, EntityManager* entities, Player* player, Graph<SGD::Point*>& _navGraph, std::vector<SGD::Rectangle*>& FOVCollidables, std::vector<int>& waypoints, const char* pEvent = nullptr);
	void CreatePickUp(int type, SGD::Point pos, EntityManager* entities);
	void CreateEnvironment(int type, SGD::Point pos, vector<SGD::Rectangle*>& FOVCollidables, EntityManager* entities, const char* event = nullptr);
	void CreateShadow(int type, SGD::Point pos, EntityManager* entities);

	void CreateKeyPad(int type, SGD::Point pos, EntityManager* entities, const char* event1 = nullptr, const char* event2 = nullptr);
	void CreateDoor(int type, SGD::Point pos, EntityManager* entities,  const char* event1 = nullptr);
	void CreateAlarmButton(int type, SGD::Point pos, EntityManager* entities, const char* event = nullptr);




};



